<%@ include file="database_ini.jsp"%>

<html>
<head>
<script language="javascript">
function editRecord(serialkey){
    var f=document.form;
    f.method="post";
    f.action='edit.jsp?serialkey='+serialkey;
    f.submit();
}
function deleteRecord(serialkey){
    var f=document.form;
    f.method="post";
    f.action='delete.jsp?serialkey='+serialkey;
    f.submit();
}
</script>
</head>
<body>
<CENTER>
<%!
String blanknull(String s) {
  return (s == null) ? "" : s;
}
%>
<p>
<a href="index.jsp"><font size="3">Select another list</font></a>
<p>
<a href="insert.jsp?listname=<%=request.getParameter("listname")%>"><font size="3">Add record</font></a>
<br><br>
<form method="post" name="form">
<table border="1">
<tr><th>listname</th><th>code</th><th>description</th><th>short</th><th>long_value</th><th>notes</th></tr>
<%

String listname = request.getParameter("listname");
//debug out.println(listname);

String sql = "select * from codelkup where listname =?";

pstmt = conn.prepareStatement(sql);
pstmt.setString(1 , listname);

ResultSet rs = pstmt.executeQuery();

%>

<%
while(rs.next()){
%>


<tr><td><%=blanknull(rs.getString("listname"))%></td>
<td><%=blanknull(rs.getString("code"))%></td>
<td><%=blanknull(rs.getString("description"))%></td>
<td><%=blanknull(rs.getString("short"))%></td>
<td><%=blanknull(rs.getString("long_value"))%></td>
<td><%=blanknull(rs.getString("notes"))%></td>
<td><input type="button" name="edit" value="Edit" style="background-color:#49743D;font-weight:bold;color:#ffffff;" onclick="editRecord(<%=rs.getString("serialkey")%>);" ></td>
<td><input type="button" name="delete" value="Delete" style="background-color:#ff0000;font-weight:bold;color:#ffffff;" onclick="deleteRecord(<%=rs.getString("serialkey")%>);" ></td>
<td><input type="hidden" name="listname" value="<%=blanknull(rs.getString("listname"))%>"></td>
</tr>
<%
}
%>
</table>
</form>
</CENTER>
</body>
</html>